home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gcc / ixemul_src.lha / ixemul-41.0 / string / strncmp.s < prev    next >
Text File  |  1994-08-19  |  2KB  |  57 lines

  1. /*-
  2.  * Copyright (c) 1990 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * This code is derived from software contributed to Berkeley by
  6.  * the Systems Programming Group of the University of Utah Computer
  7.  * Science Department.
  8.  *
  9.  * Redistribution and use in source and binary forms are permitted
  10.  * provided that: (1) source distributions retain this entire copyright
  11.  * notice and comment, and (2) distributions including binaries display
  12.  * the following acknowledgement:  ``This product includes software
  13.  * developed by the University of California, Berkeley and its contributors''
  14.  * in the documentation or other materials provided with the distribution
  15.  * and in all advertising materials mentioning features or use of this
  16.  * software. Neither the name of the University nor the names of its
  17.  * contributors may be used to endorse or promote products derived
  18.  * from this software without specific prior written permission.
  19.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  20.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  21.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  22.  */
  23.  
  24. #if defined(LIBC_SCCS) && !defined(lint)
  25.     .asciz "@(#)strncmp.s    5.1 (Berkeley) 5/12/90"
  26. #endif /* LIBC_SCCS and not lint */
  27.  
  28. #include "DEFS.h"
  29.  
  30. /*
  31.  * NOTE: this guy returns result compatible with the VAX assembly version.
  32.  * The C version on the portable gen directory returns different results
  33.  * (different signs!) when comparing chars with the high bit on.  Who is
  34.  * right??
  35.  */
  36. ENTRY(strncmp)
  37.     movl    sp@(12),d1    /* count */
  38.     jeq    scdone        /* nothing to do */
  39.     movl    sp@(4),a0    /* a0 = string1 */
  40.     movl    sp@(8),a1    /* a1 = string2 */
  41. scloop:
  42.     movb    a0@+,d0        /* get *string1 */
  43.     cmpb    a1@+,d0        /* compare a byte */
  44.     jne    scexit        /* not equal, break out */
  45.     tstb    d0        /* at end of string1? */
  46.     jeq    scdone        /* yes, all done */
  47.     subql    #1,d1        /* no, adjust count */
  48.     jne    scloop        /* more to do, keep going */
  49. scdone:
  50.     moveq    #0,d0        /* strings are equal */
  51.     rts
  52. scexit:
  53.     subb    a1@-,d0        /* *string1 - *string2 */
  54.     extw    d0
  55.     extl    d0
  56.     rts
  57.